﻿using Microsoft.Owin.Security;
using System.Collections.Generic;
using System.Linq;

namespace Sustainalytics.LongRunningTaskManager.Service
{
    /// <summary>
    /// LRTM User.
    /// </summary>
    public class LongRunningTaskManagerUser
    {
        /// <summary>
        /// User authentication ticket.
        /// </summary>
        public AuthenticationTicket Ticket { get; set; }

        /// <summary>
        /// User connections.
        /// </summary>
        public SortedSet<string> Connections { get; set; }


        /// <summary>
        /// Ctor.
        /// </summary>
        /// <param name="username"> Username. </param>
        /// <param name="ticket"> Authentication ticket. </param>
        public LongRunningTaskManagerUser(AuthenticationTicket ticket, IEnumerable<string> connections)
        {
            this.Ticket = ticket;

            if (connections != null && connections.Count() != 0)
            {
                this.Connections = new SortedSet<string>(connections);
            }
            else
            {
                this.Connections = new SortedSet<string>();
            }
        }
    }
}
